package chapter08

/**
  * 匹配对象方式二
  */
object Test05_MatchCaseClass {

  def main(args: Array[String]): Unit = {
    val yi = Student2("yi", 20)
    // 针对对象实例的内容进行匹配
    val result: String = yi match {
      case Student2("yi", 20) => "yi 20"
      case _ => "else people"
    }
    println(result)
  }
}

// 定义样例类,相当于实现了apply 和unapply方法
case class Student2( name:String, age :Int)
